package com.wow.app.dal.impl;

import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.wow.app.dal.UserDAO;
import com.wow.app.dal.dto.UserDO;

public class UserDAOImpl extends SqlMapClientDaoSupport implements UserDAO {

	@Override
	public int addUser(UserDO userDO) {
		return (Integer) this.getSqlMapClientTemplate().insert("user.add_user",
				userDO);
	}

	@Override
	public void updateUser(UserDO userDO) {
		this.getSqlMapClientTemplate().update("user.update_user", userDO);
	}

	@Override
	public void deleteUserById(int id) {
		this.getSqlMapClientTemplate().delete("user.delete_user_by_id", id);
	}

	@Override
	public UserDO getUserById(int id) {
		return (UserDO) this.getSqlMapClientTemplate().queryForObject(
				"user.query_user_by_id", id);
	}

	@Override
	public List<UserDO>getUserListByType(int type){
		return this.getSqlMapClientTemplate().queryForList("user.get_user_list_by_type",type);
	}

	@Override
	public UserDO getUserByName(String name) {
		return (UserDO) this.getSqlMapClientTemplate().queryForObject(
				"user.get_use_by_namer", name);
	}

}
